package com.kingsoft.dc.khaos.extender.meta.model;

import java.io.Serializable;

/**
 * Created by jing on 19/8/7.
 */
public class AuthTable implements Serializable{
    private String dbName;

    private String tblName;

    private String[] privSet;
    public AuthTable(){
    }


    public AuthTable(String dbName, String tblName, String[] privSet) {
        this.dbName = dbName;
        this.tblName = tblName;
        this.privSet = privSet;
    }

    public AuthTable(String fullTableName, String[] privSet) {
        if (fullTableName.contains(".")) {
            int index = fullTableName.indexOf(".");
            this.dbName = fullTableName.substring(0, index);
            this.tblName = fullTableName.substring(index + 1);
        } else {
            this.dbName = "default";
            this.tblName = fullTableName;
        }
        this.privSet = privSet;
    }

    public AuthTable(String fullTableName) {
        if (fullTableName.contains(".")) {
            int index = fullTableName.indexOf(".");
            this.dbName = fullTableName.substring(0, index);
            this.tblName = fullTableName.substring(index + 1);
        } else {
            this.dbName = "default";
            this.tblName = fullTableName;
        }
    }

    public String getDbName() {
        return dbName;
    }

    public void setDbName(String dbName) {
        this.dbName = dbName;
    }

    public String getTblName() {
        return tblName;
    }

    public void setTblName(String tableName) {
        this.tblName = tableName;
    }

    public String[] getPrivSet() {
        return privSet;
    }

    public void setPrivSet(String[] privSet) {
        this.privSet = privSet;
    }
}
